<template>
    <div>
        <h2 align="center">添加理疗项目</h2>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">项目编号</td>
                    <td><input type="text"  v-model="info.num" disabled></td>
                </tr>
                <tr>
                    <td align="right"><span style="color: red;">*</span>项目名称</td>
                   <td><input type="text"  v-model="info.shopName" ></td>
                </tr>
                <tr>
                    <td align="right"><span style="color: red;">*</span>状态</td>
                    <td>
                        <input type="radio"  v-model="info.state" :value="1" name="state">启用
                        <input type="radio"  v-model="info.state" :value="2" name="state">禁用
                    </td>
                </tr>
                <tr>
                    <td align="right"><span style="color: red;">*</span>服务人数</td>
                    <td><input type="text"  v-model="info.people"></td>
                </tr>
                <tr>
                    <td align="right"><span style="color: red;">*</span>服务时长</td>
                    <td><input type="text"  v-model="info.time"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="确定" class="btn btn-info" @click="add"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import router from "@/router";
import axios from "axios";
import moment from "moment";
import { ref,reactive,onMounted } from "vue";

let info:any=reactive({
    num: moment(new Date()).format('YYYYMMDD')+Math.random().toString().substring(2,5),
    shopName: "",
    state: "",
    people: "",
    time: "",
    isDel: ""
})


const add=()=>{
    if(info.shopName=="")
    {
        alert("项目名称不能为空");
        return;
    }
     if(info.state==0)
    {
        alert("状态不能为空");
        return;
    }
     if(info.people=="")
    {
        alert("服务人数不能为空");
        return;
    }
    // if(!isNaN(info.people))
    // {
    //      alert("必须是整数");
    //     return;
    // }
     if(info.time=="")
    {
        alert("服务时长不能为空");
        return;
    }
    axios({
        url:"https://localhost:7210/api/Shop/AddShop",
        method:'post',
        data:info
    })
    .then((res)=>{
        console.log(res);
        if(res.data>0)
        {
            alert("添加理疗项目成功");
            router.push('/showshop');
            return;
        }
        else
        {
            alert("添加失败");
            return
        }
    })
    .catch((err)=>{
         console.log(err);
    })
}


</script>

<style scoped>

</style>